
#include "StdAfx.h"
#include "FLL_NXT_Navigation_Robot.h"

using namespace System::Configuration;

FLL_NXT_Navigation_Robot::FLL_NXT_Navigation_Robot(void)
{
}

FLL_NXT_Navigation_Robot::~FLL_NXT_Navigation_Robot(void)
{
}

void FLL_NXT_Navigation_Robot::ReadAppSettings()
{
	//read from app.config
	WheelBase = System::Convert::ToDouble(ConfigurationManager::AppSettings["WheelBase"]);   
	WheelTrack = System::Convert::ToDouble(ConfigurationManager::AppSettings["WheelTrack"]);   
	WheelDiameter = System::Convert::ToDouble(ConfigurationManager::AppSettings["WheelDiameter"]);   
	RotationsPerInch = System::Convert::ToDouble(ConfigurationManager::AppSettings["RotationsPerInch"]);   
	RotationsPerDegree = System::Convert::ToDouble(ConfigurationManager::AppSettings["RotationsPerDegree"]);   
}
void FLL_NXT_Navigation_Robot::WriteAppSettings(){
	//write values to app.config file
	System::Configuration::Configuration ^config = ConfigurationManager::OpenExeConfiguration(ConfigurationUserLevel::None);
			
	config->AppSettings->Settings->Remove("WheelBase"); 
	config->AppSettings->Settings->Add("WheelBase", WheelBase.ToString("0.000"));
	config->Save(ConfigurationSaveMode::Modified);
	ConfigurationManager::RefreshSection("appSettings");

	config->AppSettings->Settings->Remove("WheelTrack"); 
	config->AppSettings->Settings->Add("WheelTrack", WheelTrack.ToString("0.000"));
	config->Save(ConfigurationSaveMode::Modified);
	ConfigurationManager::RefreshSection("appSettings"); 

	config->AppSettings->Settings->Remove("WheelDiameter"); 
	config->AppSettings->Settings->Add("WheelDiameter", WheelDiameter.ToString("0.000"));
	config->Save(ConfigurationSaveMode::Modified);
	ConfigurationManager::RefreshSection("appSettings"); 

	config->AppSettings->Settings->Remove("RotationsPerInch"); 
	config->AppSettings->Settings->Add("RotationsPerInch", RotationsPerInch.ToString("0.000"));
	config->Save(ConfigurationSaveMode::Modified);
	ConfigurationManager::RefreshSection("appSettings"); 
}